<?php
declare (strict_types=1);

namespace app\controller;

use EasyWeChat\Work\GroupRobot\Messages\Markdown;

class WorkWechat extends Wechat
{
    /**
     * 向企业微信推送消息
     * @return bool
     */
    public function sendMessage($msg)
    {
        try {
//        https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=46e723f3-b391-471e-9b48-17e28aa7464b
            // 获取 Messenger 实例
            $messenger = $this->getWechatApp()->group_robot_messenger;
            // 群组 key
            $groupKey = '46e723f3-b391-471e-9b48-17e28aa7464b';
//            $markdown = new Markdown($msg);
            $messenger->message($msg)->toGroup($groupKey)->send();
            return true;
        } catch (\Exception $e) {
            throw $e;
        }
    }
}
